from sqlalchemy import Boolean, Column, ForeignKey, Integer, String
from sqlalchemy.orm import relationship

from src.config.database_sqlalchemy import Base


class User(Base):
    __tablename__: str = "user"
    __table_args__ = {"schema": "cricetubar"}

    id = Column(String, primary_key=True)
    name = Column(String, unique=True, index=True)
    phone = Column(String)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}

    # 设置外键关系等
    # items = relationship("Item", back_populates="owner")
